﻿function Get-TSMAdminSchedule {    
    <#
        .SYNOPSIS
            Get TSM admin schedules
                    
        .DESCRIPTION
            The Get-TSMAdminSchedule returns admin schedules

        .PARAMETER Schedule
            The schedule to search

        .EXAMPLE
            Get-TSMAdminSchedule

        .NOTES
            Contributors:  David Seibel
            Last Revision Date: 09/01/2015

    #>
    [CmdletBinding()]
    Param(
        [Parameter(Position = 0)]
        $Schedule
    )
    
    $whereProps = @()
    $whereProps += [PSCustomObject]@{ "Column" = "SCHEDULE_NAME"; "Operator" = "LIKE"; "Value" = $Schedule }

    $query = Format-TSMQuery -Table "ADMIN_SCHEDULES" -Where $whereProps -OrderBy "SCHEDULE_NAME"
    $result = Invoke-TSMCommand -Command $query
    
    $defaultDisplaySet = 'SCHEDULE_NAME','STARTDATE','STARTTIME'
    $typeDefinitions = @{
                        "STARTDATE"  = [DateTime]
                        "CHG_TIME"   = [DateTime]
                        "PRIORITY"   = [Int32]
                        "DURATION"   = [Int32]
                        "MAXRUNTIME" = [Int32]
                        "PERIOD"     = [Int32]
                        }

    return Format-TSMData -Data $result -TypeDefinitions $typeDefinitions -DefaultDisplaySet $defaultDisplaySet
}